package com.yh.tomcat;

import com.yh.SpringbootDemoApplication;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

import javax.servlet.ServletException;

/**
 * @author yuanhao
 * @version 1.0
 * @description
 * @email yuanhao@yinhai.com
 * @date 2022/4/14 11:15
 */
public class MySpringApplication {
    public static void run() {
        //创建tomcat实例
        Tomcat tomcat = new Tomcat();
        //设置tomcat端口
        tomcat.setPort(8080);
        try {
            //设置项目文件的目录
            tomcat.addWebapp("/","E:\\myTest");
            tomcat.start();
            tomcat.getServer().await();
        } catch (LifecycleException e) {
            e.printStackTrace();
        } catch (ServletException e) {
            e.printStackTrace();
        }
    }
}
